<template>
  <div class="btn">
    <van-goods-action>
   <van-goods-action-icon icon="service-o" text="客服" />
      <van-goods-action-icon icon="shopping-cart-o" text="订单" @click="toOrder" />

      <van-goods-action-icon
        icon="star"
        v-show="!yes"
        text="已收藏"
        color="#ff5000"
      />
      <van-goods-action-icon
        icon="star"
        v-show="yes"
        text="喜欢"
        color="#ccc"
      />
      <van-goods-action-button type="warning" text="加入收藏" @click="add()" />
      <van-goods-action-button
      color="red"
        type="danger"
        text="立即购买"
        @click="toBuyTicket"
      />
    </van-goods-action>
  </div>
</template>
<script>
// import { Toast } from "vant";
import { GetdetailAPI } from "@/api/api.js";
import { mapState } from "vuex";
export default {
  name: "VueMovieBtnBox",
  props: ["Detail"],
  data() {
    return {
      yes: true,
    };
  },

  mounted() {
    this.$nextTick(function () {
      for (let i = 0; i < this.wantSee.length; i++) {
        const element = this.wantSee[i];
        if (element.id == this.Detail.id) {
          this.yes = false;
        }
      }
    });
  },
  computed: {
    ...mapState(["wantSee"]),
  },
  methods: {
    // toxiaoluo(){
    //  Toast("未开放")
    // },
     toOrder() {
      this.$router.push("/orderlist");
    },
    toBuyTicket() {
      let { id, nm } = { id: this.Detail.id, nm: this.Detail.nm };
      this.$router.push({
        path: "/buyticket",
        query: { id, nm },
      });
    },
    add() {
      GetdetailAPI({ movieid: this.Detail.id }).then((res) => {
        this.Details = res.data.movie;
        if (res.status == 200) {
          const Details = res.data.movie;
          this.$store.commit("AADTOSEE", Details);
          this.yes = false;
        }
      });
    },
  },
};
</script>

<style lang="less" scoped>
</style>